home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 14 / Example 14.1 / Debug / Shaders / teamCol.ps < prev    next >
Encoding:
Text File  |  2006-06-22  |  1.0 KB  |  25 lines

  1. //////////////////////////////////////////////////////////////////////////
  2. //                                                                      //
  3. //                        Unit Pixelshader                              //
  4. //                                                                      //
  5. //                   Written by C. Granberg, 2006                       //
  6. //                                                                      //
  7. //////////////////////////////////////////////////////////////////////////
  8.  
  9. sampler unitTexture;
  10. sampler fogOfWarTexture;
  11. uniform extern float4 tmCol;
  12.  
  13. float4 Main(float4 vertCol : COLOR, float2 UV : TEXCOORD0, float2 UV2 : TEXCOORD1, float shade : TEXCOORD2) : COLOR
  14. {
  15.     float4 c0 = tex2D(unitTexture, UV);
  16.     float4 light = tex2D(fogOfWarTexture, UV2);
  17.  
  18.     //Calculate alpha inverse
  19.     float Inv = 1.0f - c0.a;
  20.  
  21.     //Calculate team color
  22.     float4 color = float4(c0.rgb * Inv + tmCol.rgb * c0.a, 1.0f);
  23.  
  24.     return color * light * vertCol * shade;
  25. }